﻿package com.tudou.home.newskin.panel
{
    import com.tudou.home.newskin.consts.*;
    import com.tudou.home.newskin.containers.*;
    import com.tudou.home.newskin.events.*;
    import com.tudou.skin.*;
    import com.tudou.skin.common.events.*;
    import com.tudou.utils.*;
    import flash.display.*;
    import flash.events.*;

    public class PlayListPanel extends Sprite implements IPlayList, ITransform, IButtonState
    {
        private var freezeSprite:Sprite;
        private var left:InteractiveObject;
        private var playListRadio:PlayListRadioSprite;
        private var right:InteractiveObject;
        private var background:DisplayObject;

        public function PlayListPanel()
        {
            background = RectDisplayUtil.getShape();
            addChild(background);
            left = new RollBackwardBTN();
            left.addEventListener(MouseEvent.CLICK, leftRightHlr);
            addChild(left);
            right = new RollForwardBTN();
            right.addEventListener(MouseEvent.CLICK, leftRightHlr);
            addChild(right);
            playListRadio = new PlayListRadioSprite();
            addChild(playListRadio);
            freezeSprite = RectDisplayUtil.getSprite(100, 75, 0, NewSkinConsts.FREEZE_ALPHA);
            addChild(freezeSprite);
            playListRadio.addEventListener(RadioEvent.CLICK, radioHlr);
            freezeSprite.visible = false;
            return;
        }// end function

        public function goTransform(param1:uint, param2:uint, param3:Boolean) : void
        {
            param2 = NewSkinConsts.PLAYLIST_HEIGHT;
            background.width = param1;
            background.height = param2;
            left.x = 0;
            playListRadio.x = left.width;
            right.x = param1 - right.width;
            freezeSprite.width = param1;
            freezeSprite.height = param2;
            playListRadio.goTransform(param1 - left.width - right.width, param2, param3);
            return;
        }// end function

        public function setIndex(param1:int) : void
        {
            playListRadio.setIndex(param1);
            return;
        }// end function

        private function radioHlr(event:RadioEvent) : void
        {
            dispatchEvent(new SkinEvent(SkinEvent.THIS_INDEX, event.clickIndex));
            return;
        }// end function

        public function getIndex() : int
        {
            return playListRadio.getIndex();
        }// end function

        private function leftRightHlr(event:MouseEvent) : void
        {
            if (event.target == left)
            {
                playListRadio.rollLeft(true);
            }
            else
            {
                playListRadio.rollLeft(false);
            }
            return;
        }// end function

        public function setPlayList(param1:Array) : void
        {
            playListRadio.setPlayList(param1);
            return;
        }// end function

        public function set freeze(param1:Boolean) : void
        {
            return;
        }// end function

    }
}
